import UnsignedChar
import time
from machine import Pin
# /********************金逸晨**************************
# *****************1.3 4PIN IIC OLED FOR Arduino*************
# *****3----3SCK,   4----4SDA,
# *****BY:GU
#   1.3寸旋转90度显示，结合取模方式，及翻转命令完成旋转显示
#   *A0,C0 完成180读旋转
# ********************************************************/
OLED_COLUMN_NUMBER= 128
OLED_LINE_NUMBER= 64
OLED_COLUMN_OFFSET= 2
OLED_PAGE_NUMBER= (OLED_LINE_NUMBER/8)
IIC_SCK=  Pin(8, Pin.OUT)
IIC_SDA=  Pin(7, Pin.OUT)
LOW = 0
HIGH = 1

redLedPin = Pin(1, Pin.OUT)

def delay_us(time_us):
  time.sleep_ms(time_us)

def digitalWrite(pin,value):
  pin.value(value)
 

# /**************************IIC模块发送函数************************************************
# 
#  *************************************************************************/
# //写入  最后将SDA拉高，以等待从设备产生应答
def  IIC_write(unsigned char date):
  unsigned char i, temp;
  temp = date;
  for (i = 0; i < 8; i++)
  { digitalWrite(IIC_SCK, LOW);
    
    if ((temp & 0x80) == 0)
      digitalWrite(IIC_SDA, LOW);
    else digitalWrite(IIC_SDA, HIGH);
    temp = temp << 1;
#     //最少250ns延时
    digitalWrite(IIC_SCK, HIGH);
  }
  digitalWrite(IIC_SCK, LOW)
  digitalWrite(IIC_SDA, HIGH)
  digitalWrite(IIC_SCK, HIGH)
#   //不进行应答检测
  digitalWrite(IIC_SCK, LOW)
  
print("start")  
delay_us(1000)

digitalWrite(redLedPin, HIGH)
print("end")  